package SV_UMD_MAIN;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Example extends HttpServlet{

        public void doGet(HttpServletRequest req,
                          HttpServletResponse res) throws ServletException,
                IOException {
            res.setContentType("text/html");
            PrintWriter out = res.getWriter();
            String name = req.getParameter("name");
            out.println("<HTML>");
            out.println("<HEAD><TITLE>Hello, " + name
                    + "</TITLE></HEAD>");
            out.println("<BODY>");
            out.println("Hello, " + name);
            out.println("</BODY></HTML>");
        }
        public String getServletInfo() {
            return "A servlet that knows "
                    + "the name of the person to whom it's"
                    + "saying hello";
        }
        private void work() {
            // test some code within our application
        }
        // leaving this around is unwanted once in production
        public static void main(String[] args) {
            Example ex = new Example();
            // test that our code is working
            ex.work();
        }

}
